home *** CD-ROM | disk | FTP | other *** search
/ A.C.E. 2 / ACE CD 2.iso / FILES / UTILS / AMOSPRO4.DMS / in.adf / Tutorials / AMAL / AMAL_1.AMOS / AMAL_1.amosSourceCode
Encoding:
AMOS Source Code  |  1992-09-28  |  6.3 KB  |  183 lines

  1. '*************************** 
  2. '*    AMOS Professional    * 
  3. '*                         * 
  4. '*         AMAL_1          *            Getting started with amal  
  5. '*                         * 
  6. '* (c) Europress Software  * 
  7. '*                         * 
  8. '*     Ronnie Simpson      * 
  9. '*************************** 
  10. '
  11. '------------------------------------------- 
  12. 'AMAL (AMos Animation Language)  
  13. '------------------------------------------- 
  14. 'Amal is a separate language within Amos Professional which is optimised for 
  15. 'speed, up to 16 Amal channels can be used at a time driven under interupts  
  16. 'and these will be running independantly of your main program.   
  17. 'Each Amal program is compiled before runtime to further increase the speed
  18. 'of execution. 
  19. 'As a default channels 0-7 are allocated to the hardware sprites and 
  20. 'channels 8-15 to the relevant computed sprites, but commands are included 
  21. 'to allow channels to be assigned to other tasks such as:- 
  22. '
  23. '           Blitter objects (bobs) 
  24. '           Screen Display 
  25. '           Screen Offset  
  26. '           Screen Size  
  27. '           Rainbows 
  28. '
  29. '------------------------------------------- 
  30. 'Creating a simple Amal Program  
  31. '------------------------------------------- 
  32. 'Amal programs are defined in a string using short keywords consisting of
  33. 'only one or two letters in upper case, anything typed in lower case will
  34. 'be ignored, this allows you to pad out the instructions to make things  
  35. 'more readable for example:- 
  36. '
  37. '      A$="M50,50,100"   may be typed as    A$="Move 50,50,100"
  38. '
  39. 'Amal channels are assigned to the strings by use of the Amal instruction. 
  40. '
  41. 'eg.       Amal 1,A$ 
  42. '
  43. 'And the animation is started by use of the Amal On instruction, if an 
  44. 'optional channel number is included then only this channel is started 
  45. 'otherwise it will start all channels that have a program assigned to them.
  46. '
  47. 'eg.       Amal On 2   (start only channel number 2) 
  48. '          Amal On     (start all amal channels) 
  49. '
  50. 'Since lower case letters are ignored Amal instructions may be separated by
  51. 'any unused characters including spaces but to avoid headaches and increase  
  52. 'readability try using the ; character.
  53. '
  54. 'Please note that the : (colon) is reserved for defining a label in Amal.
  55. '  
  56. '------------------------------------------- 
  57. 'The Amal Move Instruction 
  58. '------------------------------------------- 
  59. 'Keyword M   
  60. '
  61. '              +--->total horizontal movement    
  62. '              |   +--->total vertical movement
  63. '              |   |  +--->number of steps   
  64. '           M 100,100,50 
  65. '
  66. '          
  67. 'If the above, instruction was controlling a sprite or bob whose starting  
  68. 'coordinate was 100,100 then the object would be progressively moved to
  69. '200,200 in 50 steps.  
  70. 'If the horizontal movement is positive then the object will be moved to 
  71. 'the right, if negative it will be moved to the left.  
  72. 'If the Vertical movement is positive then the object will be moved down,
  73. 'if negative it will be moved upwards.   
  74. 'The lower the number of steps the faster the movement appears.  
  75. '
  76. '------------------------------------------- 
  77. 'Amal Jump instruction 
  78. '------------------------------------------- 
  79. 'Keyword J   
  80. '
  81. 'Labels are defined in amal by placing a : (colon) after any single upper- 
  82. 'case letter, these labels then become the target for your Jump instructions.  
  83. '
  84. 'eg.        A$="L: Move 100,0,100; Move -100,0,100; Jump L"    
  85. '
  86. 'The above example would move your object 100 units to the right followed by 
  87. '100 units to the left and the jump instruction returns control to the label 
  88. 'L: resulting in both move instructions being continually repeated.  
  89. '
  90. 'As with all other amal commands the label name can be padded out with lower 
  91. 'case characters, the L: may be typed in as Label: for example.
  92. '------------------------------------------- 
  93. 'Amal Anim instruction 
  94. '------------------------------------------- 
  95. 'Keyword A   
  96. '
  97. 'The amal Anim instruction will cycle an object through a sequence either
  98. 'continually or a given number of times. 
  99. '
  100. '             +--->number of times to be repeated
  101. '             |  +--->image number 
  102. '             |  | +--->delay in 1/50ths. of a second
  103. '             |  | |   +--->next step of sequence
  104. '           A 1,(1,2)(2,2)....(3,2)  
  105. '
  106. 'If 0 is inserted for the number of times parameter then the sequence will 
  107. 'be repeated continually.
  108. 'The image number is an image from the sprite bank.  
  109. 'The delay is the amount of time the image will be displayed before the next 
  110. 'image from the sequence is used.
  111. '
  112. '------------------------------------------- 
  113. 'A simple Amal program 
  114. '------------------------------------------- 
  115. 'Please examine this listing and try to understand the way in which an 
  116. 'amal string is put together using only the instructions introduced so far.
  117. '
  118. '
  119. Rem *** load some objects to work with and clear the screen
  120. '
  121. Load "AmosPro_Tutorial:Objects/Amal_Bobs.abk"
  122. Screen Open 0,320,200,16,Lowres : Flash Off 
  123. Get Sprite Palette : Curs Off : Cls 0
  124. '
  125. Rem *** hide the mouse pointer to release sprite 0 
  126. '  
  127. Hide 
  128. '
  129. Rem *** the Amal string definition 
  130. '
  131. Rem *** starting with the Anim 
  132. '
  133. A1$="Anim 0,(1,4)(2,4)(3,4)(4,4)"
  134. '
  135. Rem *** now we need a label to Jump to 
  136. '
  137. A2$="Label:"
  138. '
  139. Rem *** add 4 move instructions
  140. '
  141. A3$="Move -400,0,100;Move 0,-80,5;Move 400,0,5;Move 0,80,5"
  142. '
  143. Rem *** the Jump instruction will continually repeat the above moves 
  144. '
  145. A4$="Jump Label"
  146. '
  147. Rem *** now join all the above to form the complete amal string
  148. '
  149. A$=A1$+A2$+A3$+A4$
  150. '
  151. '------------------------------------------------------------------------- 
  152. Rem *** full string with padding letters removed would look like this:-  
  153. '
  154. '  Amal 0,"A0,(1,4)(2,4)(3,4)(4,4)L: M-400,0,100M0,-80,5M400,0,5M0,80,5JL" 
  155. '
  156. '------------------------------------------------------------------------- 
  157. '
  158. Rem *** assign an amal channel to the string 
  159. '
  160. Amal 0,A$
  161. '
  162. Rem *** set start position of the sprite off right hand edge of screen   
  163. '
  164. Sprite 0,500,100,4
  165. '
  166. Rem *** and finally start the amal program 
  167. '
  168. Amal On 
  169. '
  170. '
  171. T$="The bird is now moving independent of   the main program. If you do not believe me then press any mouse key to stop the main program and return to direct mode  .....but..... watch the BIRDIE!!!!"
  172. Paper 0 : C=4
  173. Repeat 
  174.    Locate 0,13 : Pen C
  175.    For P=1 To Len(T$)
  176.       Print Mid$(T$,P,1); : Wait 2
  177.       If Mouse Key Then Exit 2
  178.    Next 
  179.    Add C,2,4 To 6
  180. Until Mouse Key
  181. Locate 0,13 : Print T$
  182. Pen 4 : Locate 0,5 : Centre "See what I mean?"
  183. Direct